/**
 *
 */
package com.perselab.recipe.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * @author lewin.nguyen
 *
 */
@Entity
@Table(name="image")
public class Image extends AbstractModel implements Auditable {
	private static final long serialVersionUID = 1302942432363276609L;

	private Long id;
	private String path;
	private String name;
	private String extension;
	private String title;
	private String description;
	private int width;
	private int height;
	private long size;
	private User owner;
	private String mimeType;
	private int status;
	private Date creationDate;
	private Date modificationDate;

	/**
	 * @return the id
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	/**
	 * @return the path
	 */
	@Column(length = 1000)
	public String getPath() {
		return path;
	}

	/**
	 * @return the name
	 */
	@Column(length = 255)
	public String getName() {
		return name;
	}

	/**
	 * @return the title
	 */
	@Column(length = 255)
	public String getTitle() {
		return title;
	}

	/**
	 * @return the description
	 */
	@Lob
	public String getDescription() {
		return description;
	}

	/**
	 * @return the extension
	 */
	@Column(length = 50)
	public String getExtension() {
		return extension;
	}

	/**
	 * @return the mimeType
	 */
	@Column(length = 50)
	public String getMimeType() {
		return mimeType;
	}

	/**
	 * @return the width
	 */
	@Column
	public int getWidth() {
		return width;
	}

	/**
	 * @return the size
	 */
	@Column
	public long getSize() {
		return size;
	}

	/**
	 * @return the owner
	 */
	@ManyToOne
	@JoinColumn(name = "user_id")
	public User getOwner() {
		return owner;
	}

	/**
	 * @return the height
	 */
	@Column
	public int getHeight() {
		return height;
	}

	/**
	 * @return the status
	 */
	@Column
	public int getStatus() {
		return status;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @param path
	 *            the path to set
	 */
	public void setPath(String path) {
		this.path = path;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @param extension
	 *            the extension to set
	 */
	public void setExtension(String extension) {
		this.extension = extension;
	}

	/**
	 * @param width
	 *            the width to set
	 */
	public void setWidth(int width) {
		this.width = width;
	}

	/**
	 * @param mimeType
	 *            the mimeType to set
	 */
	public void setMimeType(String mimeType) {
		this.mimeType = mimeType;
	}

	/**
	 * @param height
	 *            the height to set
	 */
	public void setHeight(int height) {
		this.height = height;
	}

	/**
	 * @param status
	 *            the status to set
	 */
	public void setStatus(int status) {
		this.status = status;
	}

	/**
	 * @param title
	 *            the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * @param description
	 *            the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @param owner
	 *            the owner to set
	 */
	public void setOwner(User owner) {
		this.owner = owner;
	}

	/**
	 * @param size
	 *            the size to set
	 */
	public void setSize(long size) {
		this.size = size;
	}

	/**
	 * @return the creationDate
	 */
	@Column(name = "creation_date")
	public Date getCreationDate() {
		return creationDate;
	}

	/**
	 * @param creationDate
	 *            the creationDate to set
	 */
	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	/**
	 * @return the modificationDate
	 */
	@Column(name = "modification_date")
	public Date getModificationDate() {
		return modificationDate;
	}

	/**
	 * @param modificationDate
	 *            the modificationDate to set
	 */
	public void setModificationDate(Date modificationDate) {
		this.modificationDate = modificationDate;
	}

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof Image)) {
			return false;
		}
		Image rhs = (Image) object;
		return new EqualsBuilder().append(this.status, rhs.status)
				.append(this.width, rhs.width).append(this.size, rhs.size)
				.append(this.id, rhs.id).append(this.extension, rhs.extension)
				.append(this.title, rhs.title).append(this.height, rhs.height)
				.append(this.description, rhs.description)
				.append(this.name, rhs.name).append(this.path, rhs.path)
				.append(this.owner, rhs.owner)
				.append(this.mimeType, rhs.mimeType).isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-512596701, 79629379).append(this.status)
				.append(this.width).append(this.size).append(this.id)
				.append(this.extension).append(this.title).append(this.height)
				.append(this.description).append(this.name).append(this.path)
				.append(this.owner).append(this.mimeType).toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
				.append("status", this.status).append("owner", this.owner)
				.append("description", this.description)
				.append("height", this.height).append("name", this.name)
				.append("path", this.path).append("title", this.title)
				.append("extension", this.extension)
				.append("width", this.width).append("size", this.size)
				.append("id", this.id).append("mimeType", this.mimeType)
				.toString();
	}
}
